package com.ruoyi.syf.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.syf.domain.EscalationLog;
import com.ruoyi.syf.service.IEscalationLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 上报记录
 *
 * @author yr
 * @date 2024-08-26
 */
@RestController
@RequestMapping("/syf/escalationLog")
public class EscalationLogController extends BaseController {
    @Autowired
    private IEscalationLogService escalationLogService;

    /**
     * 查询上报记录列表
     */
    @PreAuthorize("@ss.hasPermi('syf:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(EscalationLog escalationLog) {
        startPage();
        List<EscalationLog> list = escalationLogService.list(escalationLog);
        return getDataTable(list);
    }

    /**
     * 导出上报记录列表
     */
    @PreAuthorize("@ss.hasPermi('syf:log:export')")
    @Log(title = "上报记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EscalationLog escalationLog) {
        List<EscalationLog> list = escalationLogService.list(escalationLog);
        ExcelUtil<EscalationLog> util = new ExcelUtil<EscalationLog>(EscalationLog.class);
        util.exportExcel(response, list, "上报记录数据");
    }

    /**
     * 删除上报记录
     */
    @PreAuthorize("@ss.hasPermi('syf:log:remove')")
    @Log(title = "上报记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(escalationLogService.deleteEscalationLogByIds(ids));
    }
}
